package com.ruoyi.api.client.api;

import com.ruoyi.api.client.domain.vo.HomeInfoVo;
import com.ruoyi.api.client.domain.vo.MineInfoVo;
import com.ruoyi.api.client.domain.vo.SysDictDataVo;
import com.ruoyi.api.client.domain.vo.UploadVo;
import com.ruoyi.api.client.service.IClientCommonService;
import com.ruoyi.common.annotation.SaClientCheckLogin;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Description 客户端-通用模块API
 * @Author zouhuu
 * @Date 2022/8/3 10:25
 */
@Api(tags = "客户端-通用模块API")
@RestController
@RequestMapping("/api/client/common")
public class CommonApi {

    @Autowired
    private IClientCommonService clientCommonService;

    @ApiOperation("首页信息")
    @GetMapping("/home/info")
    public R<HomeInfoVo> homeInfo()  {
        return clientCommonService.homeInfo();
    }

    @ApiOperation("个人中心菜单")
    @GetMapping("/user/menu")
    public R<MineInfoVo> userMenu() {
        return clientCommonService.userMenu();
    }

    /**
     * 首页通知接口
     * @return
     */
    @ApiOperation("首页通知")
    @SaClientCheckLogin
    @GetMapping("/home/notice")
    public R homeNotice() {
        return clientCommonService.homeNotice();
    }

    @ApiOperation("获取字典数据")
    @GetMapping(value = "/dict/data")
    public R<List<SysDictDataVo>> dictData(@ApiParam(value = "字典类型", required = true) String dictType) {
        return clientCommonService.dictData(dictType);
    }

    @ApiOperation("文件上传")
    @PostMapping("/upload/file")
    public R<UploadVo> uploadFile(@ApiParam(value = "文件", required = true) MultipartFile file) {
        return clientCommonService.uploadFile(file);
    }

}
